<?php
namespace App\Services;


use App\Models\CompanyInfo;

class CompanyPhoneService{

    public $companyInfo;

    public function  __construct()
    {
        $this->companyInfo = new CompanyInfo();
    }

    public function getRandomPhone(){
        $info = $this->companyInfo->firstOrFail();
        if ($info->phone && $info->mobile){
            $phones = [$info->phone,$info->mobile];
            $phone = $phones[array_rand($phones,1)];
        }else{
            $phone = $info->phone?$info->phone:$info->mobile;
        }
        return $phone;
    }
}
